import Vue from "vue";
import App from "./App.vue";
//引入路由
import router from "./router/router.js";
//引入全局样式
import "./assets/css/global.css";
//引入element
import "./element/element.js";
//导入字体图标
import "./assets/fonts/iconfont.css";
//引入vue-table-with-tree-grid
import TreeTable from "vue-table-with-tree-grid";
Vue.component("tree-table", TreeTable);
//引入axios
import axios from "axios";
axios.defaults.baseURL = "https://lianghj.top:8888/api/private/v1/";
////引入NProgress
import NProgress from "nprogress";
import "nprogress/nprogress.css";
axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem("login");
  return config;
});
axios.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  NProgress.done();
  return response;
});
Vue.prototype.$http = axios;
Vue.config.productionTip = false;

//引用vue-quill-editor

import quillEditor from "vue-quill-editor";

import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
Vue.use(quillEditor);

//日期过滤器
Vue.filter("dateFormat", function (val) {
  let date = new Date(val);
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let day = date.getDate();
  let hours = date.getHours();
  let minute = date.getMinutes();
  let second = date.getSeconds();
  month = month <= 9 ? "0" + month : month;
  day = day <= 9 ? "0" + day : day;
  hours = hours <= 9 ? "0" + hours : hours;
  minute = minute <= 9 ? "0" + minute : minute;
  second = second <= 9 ? "0" + second : second;
  return (
    year + "-" + month + "-" + day + " " + hours + ":" + minute + ":" + second
  );
});

new Vue({
  render: (h) => h(App),
  router,
}).$mount("#app");
